package io.renren.common.constants.enums;

import com.alibaba.fastjson.annotation.JSONType;
import lombok.Getter;

import java.util.Arrays;

/**
 * 支付状态枚举
 */
@Getter
public enum PayState implements EnumValue{
    PRE_SUCCESS(0,"预支付"),
    PAY_SUCCESS(2,"支付成功"),
    PAY_CLOSED(3,"支付关闭")
    ;

    /**值*/
    private int value;
    /**描述*/
    private String desc;

    PayState(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    /**
     * 获取枚举
     *
     * @return
     */
    public static PayState getByCode(int code) {
        return Arrays.stream(values()).filter(e -> e.getValue() == code).findFirst().orElse(PRE_SUCCESS);
    }

    @Override
    public int value() {
        return this.value;
    }
    @Override
    public String toString() {
        return this.value+"";
    }
}
